/* $Id: Scanner.h 27 2011-09-16 13:28:08Z skagget77 $ */

/*!
 * \file
 * \author  Johan Andersson <skagget77@gmail.com>
 * \date    Mon Feb 15 18:24 2010
 * \ingroup IoCpp
 * \brief   IoCpp Scanner EDSL.
 */

#if !defined(IOCPP_SCANNER_H)
#define IOCPP_SCANNER_H

#include "AndContext.h"
#include "AndWithoutExecutableContext.h"
#include "IContainer.h"
#include "ScanContext.h"

namespace IoCpp
{
   /*!
    * \author  Johan Andersson <skagget77@gmail.com>
    * \date    Mon Feb 15 18:24 2010
    * \ingroup IoCpp
    * \brief   The Scanner class, part of IoCpp Scanner EDSL.
    *
    * \details TODO: Add detailed description of Scanner EDSL.
    */
   class Scanner
   {
   public :
      /*!
       * Creates a new instance of the Scanner class.
       *
       * \param container the IoCpp container.
       */
      Scanner( IContainerPtr container )
         : mContext(new ScanContext(container)) {
      }

      /*!
       * Selects a library to scan.
       *
       * \param  library the library to scan.
       * \return An AndContext.
       */
      AndContext AddLibrary( const FileCollection::value_type& library ) const
      {
         mContext->AddLibrary(library, false);
         return AndContext(mContext);
      }

      /*!
       * Selects an optional library to scan.
       *
       * \param  library the optional library to scan.
       * \return An AndContext.
       */
      AndContext AddOptionalLibrary( const FileCollection::value_type& library ) const
      {
         mContext->AddLibrary(library, true);
         return AndContext(mContext);
      }

      /*!
       * Selects a path to scan.
       *
       * \param  path the path to scan.
       * \return An AndContext.
       */
      AndContext AddPath( const PathCollection::value_type& path ) const 
      {
         mContext->AddPath(path, false);
         return AndContext(mContext);
      }

      /*!
       * Selects an optional path to scan.
       *
       * \param  path the optional path to scan.
       * \return An AndContext.
       */
      AndContext AddOptionalPath( const PathCollection::value_type& path ) const 
      {
         mContext->AddPath(path, true);
         return AndContext(mContext);
      }

      /*!
       * Selects to scan the current executable.
       *
       * \return An AndWithoutExecutableContext.
       */
      AndWithoutExecutableContext AddExecutable() const 
      {
         mContext->AddExecutable();
         return AndWithoutExecutableContext(mContext);
      }

      /*!
       * Scans all added libraries and paths.
       *
       * \throws LibraryNotFoundException
       * \throws PathNotFoundException
       */
      void Scan() const {
         mContext->Scan();
      }

   private :
      ScanContextPtr mContext;
   };
}

#endif   // IOCPP_SCANNER_H
